package cc.demo02;

import java.lang.reflect.Method;

/**
 * @author ${崔灿}
 * @date 2022/10/27 17:56
 **/

public class Test03 {
    public static void main(String[] args) throws Exception{
        Class<?> aClass = Class.forName("cc.demo02.Cat1");
        Method fun1 = aClass.getDeclaredMethod("fun1");
        Object o = aClass.newInstance();
        Object invoke = fun1.invoke(o);
        System.out.println(invoke);
        Method fun2 = aClass.getDeclaredMethod("fun2", String.class, Integer.class);
        Object l = fun2.invoke(o, "刘德华", 78);
        System.out.println(l);
    }
}
class Animal1{
    public void show(){
        System.out.println("动物的show方法");
    }
    private void print(){
        System.out.println("动物的print方法");
    }
}
class Cat1 extends  Animal1{
    public void fun1(){
        System.out.println("Cat中的fun1方法");
    }
    public String fun2(String name,Integer age){
        System.out.println("cat中fun2方法"+name);
        return "呵呵呵呵";
    }
}